package com.ruoyi.data.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.data.domain.BondCbIndexJsl;
import com.ruoyi.data.service.IBondCbIndexJslService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 等权指数Controller
 * 
 * @author leng.xz
 * @date 2024-05-02
 */
@Controller
@RequestMapping("/data/jslIndex")
public class BondCbIndexJslController extends BaseController
{
    private String prefix = "data/jslIndex";

    @Autowired
    private IBondCbIndexJslService bondCbIndexJslService;

    @RequiresPermissions("data:jslIndex:view")
    @GetMapping()
    public String jslIndex()
    {
        return prefix + "/jslIndex";
    }

    /**
     * 查询等权指数列表
     */
    @RequiresPermissions("data:jslIndex:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BondCbIndexJsl bondCbIndexJsl)
    {
        startPage();
        List<BondCbIndexJsl> list = bondCbIndexJslService.selectBondCbIndexJslList(bondCbIndexJsl);
        return getDataTable(list);
    }

    /**
     * 导出等权指数列表
     */
    @RequiresPermissions("data:jslIndex:export")
    @Log(title = "等权指数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BondCbIndexJsl bondCbIndexJsl)
    {
        List<BondCbIndexJsl> list = bondCbIndexJslService.selectBondCbIndexJslList(bondCbIndexJsl);
        ExcelUtil<BondCbIndexJsl> util = new ExcelUtil<BondCbIndexJsl>(BondCbIndexJsl.class);
        return util.exportExcel(list, "jslIndex");
    }

    /**
     * 新增等权指数
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存等权指数
     */
    @RequiresPermissions("data:jslIndex:add")
    @Log(title = "等权指数", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BondCbIndexJsl bondCbIndexJsl)
    {
        return toAjax(bondCbIndexJslService.insertBondCbIndexJsl(bondCbIndexJsl));
    }

    /**
     * 修改等权指数
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        BondCbIndexJsl bondCbIndexJsl = bondCbIndexJslService.selectBondCbIndexJslById(id);
        mmap.put("bondCbIndexJsl", bondCbIndexJsl);
        return prefix + "/edit";
    }

    /**
     * 修改保存等权指数
     */
    @RequiresPermissions("data:jslIndex:edit")
    @Log(title = "等权指数", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BondCbIndexJsl bondCbIndexJsl)
    {
        return toAjax(bondCbIndexJslService.updateBondCbIndexJsl(bondCbIndexJsl));
    }

    /**
     * 删除等权指数
     */
    @RequiresPermissions("data:jslIndex:remove")
    @Log(title = "等权指数", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(bondCbIndexJslService.deleteBondCbIndexJslByIds(ids));
    }
}
